package com.resource.utils;

import com.resource.constant.OfficeApiConstants;
import com.resource.response.OfficeResponse;
import com.resource.spring.ApiAssert;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

/**
 * 校验
 * 
 * @Author: xianggaoxiong
 * @Date: 2020-09-25 16:43
 **/
public class ValidateUtils {
	/**
	 * 校验泛微请求返回
	 * 
	 * @param responseEntity
	 */
	public static OfficeResponse checkResponse(ResponseEntity<OfficeResponse> responseEntity) {
		ApiAssert.isFalse("HTTP请求状态返回失败：" + responseEntity.getStatusCode(),
				responseEntity.getStatusCode().equals(HttpStatus.OK));
		OfficeResponse officeResponse = responseEntity.getBody();
		ApiAssert.isNull("HTTP返回体为空", officeResponse);
		ApiAssert.isFalse("【泛微】请求返回状态失败：" + officeResponse.getStatus(),
				officeResponse.getStatus() == OfficeApiConstants.SUCCESS);
		return officeResponse;
	}
}
